package com.sdut.material.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sdut.material.pojo.SupplierMaterial;
import com.sdut.material.mapper.SupplierMaterialMapper;
import com.sdut.material.service.ISupplierMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Yu
 * @since 2022-04-20
 */
@Service
public class SupplierMaterialServiceImpl extends ServiceImpl<SupplierMaterialMapper, SupplierMaterial> implements ISupplierMaterialService {
    @Autowired
    private SupplierMaterialMapper supplierMaterialMapper;
    @Override
    public List<SupplierMaterial> selectByMaterialId(Integer materialId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("material_id",materialId);
        List<SupplierMaterial> list = supplierMaterialMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public SupplierMaterial selectByMaterialIdAndSupplierId(int supplierId, int materialId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("supplier_id",supplierId);
        queryWrapper.eq("material_id",materialId);
        return supplierMaterialMapper.selectOne(queryWrapper);
    }

    @Override
    public SupplierMaterial selectById(int supplierMaterialId) {
        return supplierMaterialMapper.selectById(supplierMaterialId);
    }
}
